package com.example.demo.synchronizationDemo;

/**
 * Created by 蔡超 on 2018/10/9.
 */
public class SynchronizationDemo {
    public static void main(String[] args) {

        Person p1 = new Person();

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    p1.m1();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                p1.m2();
            }
        }).start();


        new Thread(new Runnable() {
            @Override
            public void run() {
                p1.m2();
                try {
                    p1.m1();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).start();
    }
}
